Forums › ProRealTime English forum › ProOrder support › Automated trading with Pivot Points and Dojis › Reply To: Automated trading with Pivot Points and Dojis
I’ve not really been following this thread but thought I would test the code you have given. I think I have the same section of chart as you and mine works fine.
I do notice a couple of things in your code that are unrelated. You have declared the variable values after they are used in a condition so as code is processed from top to bottom the value in the condition will be zero rather than your desired value:
1 2 3 4 |
bullishs2d = (dojis2d and low[1] <= s2+abstl2d and low[1] >= s2-abst2d and close>high[1] and low>low[1]) abst2d = 8*pipsize abstl2d = 2*pipsize |
Also you give a value to a variable at time of market entry and then use it as a condition to set a sell stop which is unnecessary as just being on the market is sufficient conditions to set the sell stop.
1 2 3 4 5 6 7 8 9 |
if bullishs2d then ldbs2d = low[1]-2 Buy size Contract at Market endif if longonmarket and ldbs2d then sell at ldbs2d stop endif |
Also you should consider that when a position is opened the Sell Stop will not be set until one bar later as at the time of entry the condition of OnMarket is not being met so you should put the Sell Stop in at the same time as the market entry is made or use a Set Stop Loss at time of entry and then add the Sell Stop one bar later.
1 2 3 4 5 6 7 8 9 |
if bullishs2d then ldbs2d = low[1]-2 Buy size Contract at Market sell at ldbs2d stop endif if longonmarket and close < low[1] then sell at market endif |