One-time buy Signal at System Start
Forums › ProRealTime English forum › ProOrder support › One-time buy Signal at System Start
- This topic has 45 replies, 6 voices, and was last updated 1 week ago by PeterSt.
-
-
10/30/2024 at 2:47 PM #23979410/30/2024 at 2:55 PM #23979710/30/2024 at 3:26 PM #239800
I think I know why this happens. When the first position is opened, and within 36 units an opposite position should be opened by the indicator, it goes wrong because the indicator hasn’t had time to configure itself yet. You can solve this by using the period of the supertrend (36 units) as “PreLoadBars.”
So use:DefParam PreLoadBars=36
1 user thanked author for this post.
10/30/2024 at 4:00 PM #23980411/05/2024 at 8:26 AM #239962I’ve tried this code now with (DEMO) auto trading, but it doesn’t open a position, not on the system start, not the next day, also not the day after… does anyone know what the reason could be?
When i use this code for backtesting, it works fine!
1234567891011121314151617181920212223242526272829// Set code parametersDEFPARAM PreLoadBars = 100DEFPARAM CumulateOrders = False // Prevents multiple entriesONCE EntryFlag = 0 // Initialization for one-time entrysuperTrendValue = SuperTrend[5.4,36]// Check if there is no position at the start and EntryFlag is 0IF NOT ONMARKET AND EntryFlag = 0 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Long ConditionsIF NOT LONGONMARKET and close CROSSES OVER superTrendValue THENBUY 1 CONTRACT AT MARKET // Long EntryEntryFlag = 1 // Set the flag to avoid re-triggeringELSIF LONGONMARKET and close CROSSES UNDER superTrendValue THENSELL AT MARKET // Long ExitEntryFlag = 1 // Set the flag to avoid re-triggeringENDIF// Short ConditionsIF NOT SHORTONMARKET AND close CROSSES UNDER superTrendValue THENSELLSHORT 1 CONTRACT AT MARKET // Short EntryEntryFlag = 1 // Set the flag to avoid re-triggeringELSIF SHORTONMARKET and close CROSSES OVER superTrendValue THENEXITSHORT AT MARKET // Short ExitEntryFlag = 1 // Set the flag to avoid re-triggeringENDIF11/05/2024 at 9:39 AM #239963Undoubtedly PreLoadBars. It would be the only thing that matters for Backtest vs Demo (or Live for that matter).
Hence, your SuperTrend can’t cope with the 100 bars 0nly.?
PS: I see that JS already gave the same response to earlier posts. Still I think my text applies.
1 user thanked author for this post.
11/05/2024 at 10:37 AM #239966Hi Peter, with JS the last solution was to use at least PreLoadBars = 36, I’ve increased it to 100 for backtesting, it works. I have tested the system now with 1000 bars, in a 5 min. timeframe (in hope to see sooner results if the position would be opened at the next bar) but nothing happens (screenshot attached). As I am a very beginner at this, it might just be a basic setting but I just can’t figure it out.
11/05/2024 at 10:57 AM #239968Just to clarify my goal here: I’m aiming for an immediate entry into a long or short position (I’d adjust the code accordingly) as soon as I start the auto trading system, without having to wait for the next signal. We’ve only increased the PreLoadBars to ensure that the first signals from the SuperTrend indicator are accurately interpreted AFTER the immediate entry.
11/05/2024 at 11:32 AM #239969I’m aiming for an immediate entry into a long or short position
Below on Lines 9,10 and 11 of the most recent posted code will (should?) give you above (you adjust for Short or Long as you think fit when you start your Algo).
Tell us what is not happening if not above?
IF NOT ONMARKET AND EntryFlag = 0 THENSELLSHORT 1 CONTRACT AT MARKETENDIF1 user thanked author for this post.
11/05/2024 at 11:42 AM #239973Yes that’s what the code SHOULD do, and it works when I do backtesting but when I start auto trading (in Demo mode), nothing happens – no matter what timeframe i use, no positions are being opened (see screenshot attached). The system was also active for a couple of days with a 1 day timeframe, in case it opens a position at the next candle/day, but still nothing happened.
1 user thanked author for this post.
11/05/2024 at 11:53 AM #23997511/05/2024 at 11:58 AM #23997611/05/2024 at 12:16 PM #239977Below works … see attached.
Maybe somebody can tell us why??
1234567891011// Set code parametersDEFPARAM PreLoadBars = 100DEFPARAM CumulateOrders = False // Prevents multiple entriesONCE EntryFlag = 0 // Initialization for one-time entrysuperTrendValue = SuperTrend[5.4,36]// Check if there is no position at the start and EntryFlag is 0IF EntryFlag =0 THENSELLSHORT 1 CONTRACT AT MARKETENDIF11/05/2024 at 12:17 PM #239978Hi,
“PreLoadBars” does not determine the number of bars over which the backtest is conducted, but rather the number of bars loaded before the backtest is performed.
(The number of bars for your backtest is determined by the amount of “units” in your chart)
If you use “PreLoadBars=36” as discussed, it should work fine…
Opening the first position depends on your timeframe: if you use 1 day, the first position will open after 1 day, and if you use a 5-minute timeframe, then after 5 minutes…1 user thanked author for this post.
11/05/2024 at 12:31 PM #239981 -
AuthorPosts
Find exclusive trading pro-tools on