Help debugging code. Not operating everyday. Why???
Forums › ProRealTime English forum › ProOrder support › Help debugging code. Not operating everyday. Why???
- This topic has 5 replies, 2 voices, and was last updated 7 years ago by Juan Salas.
-
-
06/26/2017 at 2:13 PM #391061234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071/ FOREX BREAKOUT// 15 MIN// One trade per day, from 08:00h to 14:00. The system shuts-down at 14:00h// Everyday Channel formation from 0700 to 0800 (Highest-Lowest)// Maximum Range 32pipsDEFPARAM CUMULATEORDERS = false// OPERATIONAL TIMEDEFPARAM FLATBEFORE = 080000DEFPARAM FLATAFTER = 140000Operationaltime = TIME > 080000 AND TIME < 140000// ONE TRADE PER DAY. It resets the variable each new dayIF INTRADAYBARINDEX = 0 THENalreadytraded = 0reverse = 0ENDIF// RANGE between 0700h to 0800hIF TIME=080000 THENchannelhigh = Highest[4](high)channellow = Lowest[4](low)ENDIF// NO ACTIVITY if the range (highest-lowest)is >= 32 pipsIF channelhigh-channellow>=32*pipsize THENtradeok=0ELSEtradeok=1ENDIF// LONG Positions-OpeningIF NOT ONMARKET AND Operationaltime AND tradeok = 1 AND alreadytraded=0 THENBUY 1 CONTRACT AT channelhigh + 3*pipsize STOPalreadytraded=1reverse=1ENDIF// SHORT Positions-OpeningIF NOT ONMARKET AND Operationaltime AND tradeok = 1 AND alreadytraded=0 THENSELLSHORT 1 CONTRACT AT channellow - 3*pipsize STOPalreadytraded=2reverse=1ENDIF// TEST IF AN ORDER IS IN THE MARKETIF ONMARKET THENtradeok = 0alreadytraded = 1ENDIF// REVERSEIF reverse=1 THENIF alreadytraded=1 AND NOT ONMARKET AND POSITIONPERF(1)<0 THENSELLSHORT 1 CONTRACT AT MARKETreverse=0ENDIFIF alreadytraded=2 AND NOT ONMARKET AND POSITIONPERF(1)<0 THENBUY 1 CONTRACT AT MARKETreverse=0ENDIFENDIF// STOP & PROFITSET STOP LOSS 5*pipsizeSET TARGET PROFIT 8*pipsize
Hi everyone,
I posted this same code yesterday, and out of the blue (I don’t know why) now it does not operate everyday.
It is a very simple breakout system with a reverse stop in case that the first trade does not work.
The only problem is that only launches an average of 5-6 operations a month. I am playing with the INTRADAYBARINDEX command but nothing.
Thanks a lot,
Juan
06/26/2017 at 2:45 PM #39108Hi Juan, I answered your question in the other thread here: https://www.prorealcode.com/topic/help-identifying-a-mistake-in-this-simple-code/
Is this the same problem?
06/26/2017 at 3:15 PM #39112Hi Nicolas,
Yes and yes. You gave me a solution yesterday but it didn´t seem to work completely. I have a tried to fixed myself but I don’t know why, the system doesn’t launch operations everyday.
Ideally, it should launch one order (everyday after 08:00) once the price breaks the upper or lower limit of the channel formed with the range of the previous candlesticks (from 07:00 to 08:00), and in case of a negative outcome, it launches a reversal order after the stop loss is closed. That is it. No more trading until next day.
I made it (with your instructions) to trade once a day and to launch a reversal order after the first stop loss, but somehow it only works 10 days a month. I have also removed the Maximum Range of 32 pips for the Channel, but that is not the problem.
Thanks,
Juan
06/26/2017 at 3:54 PM #39126As I wrote yesterday in the other topic, you have to set your pending order at each bar .. but you disallow them after only 1 bar with your lines 36 and 44. So if the price doesn’t breach your upper or lower levels at the first bar, you’ll never get trade the rest of the day, because no new pending STOP orders are set!
06/26/2017 at 3:55 PM #39127Please read once again the code I posted yesterday: https://www.prorealcode.com/topic/help-identifying-a-mistake-in-this-simple-code/#post-38995
Just copy/paste.
06/26/2017 at 4:08 PM #39128Hi Nicolas,
Sorry, I will pay more attention next time. You are completely right!!! It works!!! I was just right there.
Thanks,
Juan
-
AuthorPosts
Find exclusive trading pro-tools on