Function Call to user-indicator returning no data
Forums › ProRealTime English forum › ProOrder support › Function Call to user-indicator returning no data
- This topic has 1 reply, 2 voices, and was last updated 6 years ago by
robertogozzi.
-
-
10/29/2018 at 10:39 PM #83751
Hi, I’ve written my first Indicator and am trying to call it from my trading System. The problem I have is that when I call the function from a Trading System, no data is returned.
The indicator returns a single value (in a parameter called Result) of either 1, 2 or 99 and seems to work fine when added to a chart.
The Trading System output shows a value of 0 which suggests something is wrong somewhere but I can’t seem to work it out.
Any help would be gratefully received 🙂
I’ve attached
a) the indicator code
b) my simple trading system which calls the indicator
c) a screen shot which shows the indicator on the chart. This shows that there are values in the Result parameter which the indicator returns. It also shows the Trading System variables which should show the Result value however it remains at a value of 0.
My call to my 'myClearBar' indicator1234567891011DEFPARAM cumulateorders=truemyResult=CALL myClearBarGraph myResultif myResult=1 ThenBUY 1 CONTRACTS AT MARKETENDIFIf myResult=2 THENSELL AT MARKETENDIFMyClearBar indicator which seems to work but doesn't return data via CALL12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879DEFPARAM CALCULATEONLASTBARS = 200DEFPARAM DRAWONLASTBARONLY = falsex=200 // number of bars to look back through...LH=99999999HL=0LHFound=0 // flag to indicate whether the Lowest High has been found; and the routine should now look for the Highest LowHLFound=0 // opposite of above...// keep looping through the specified number of bars so we know which is the nearest LH or HLwhile x>1 do//--------------------------------------------------------------------------------------// Reset flagsresult=99//thisBarIndex=0//--------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------// look for the most recent Lowest High bar LH)while high[x] < LH and x>0 DO // look for a new lowest high; skip when x=0LH=high[x] // set the latest LHx=x-1 // decrement the loopLHFound=1 // indicate that aLH has been foundHLFound=0 // ...and that the HL has not....wend//--------------------------------------------------------------------------------------// Output LH barif LHFound then//Draw where the LH was found...x=x+1//ThisBarIndex=BarindexDRAWTEXT("LH*", barindex-x, high[x])x=x-1//LatestLH=LH//LatestHL=0Endif//--------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------// look for the most recent Highest Low bar (HL)WHILE low[x] >HL and x>0 DO// look for a new highest low; skip when x=0HL=low[x]// set the latest HLx=x-1 // decrement the loopHLFound=1 // indicate that a HL has been foundLHFound=0 // ...and that the LH has not....WEND//--------------------------------------------------------------------------------------// Output HL barif HLFound then// Draw where the HL was found...x=x+1//LatestHL=HL//LatestLH=0//ThisBarIndex=BarindexDRAWTEXT("HL", barindex-x, low[x])x=x-1Endif//--------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------// Output signal bar on chartif close>LH and close[1]<=LH thenresult=1DRAWARROWUP(barindex, low)coloured(0,255,0)x=1// exit loopendifif close<HL and close[1]>=HL thenresult=2DRAWARROWDOWN(barindex, high)coloured(255,0,0)x=1// exit loopendif//--------------------------------------------------------------------------------------// reset these counters before re-loooping...LH=99999999HL=0wendreturn result as "Result"//, LatestHL as "HL",LatestLH as "LH", close as "Close"//, ThisBarIndex as "ThisBarIndex",barindex as "Barindex"10/30/2018 at 12:40 AM #83755Don’t call it but embed it in your strategy so that you can debug it better with GRAPH (you can graph more variables, not just the one returned):
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485DEFPARAM cumulateorders=true//x=200 // number of bars to look back through...LH=99999999HL=0LHFound=0 // flag to indicate whether the Lowest High has been found; and the routine should now look for the Highest LowHLFound=0 // opposite of above...// keep looping through the specified number of bars so we know which is the nearest LH or HLwhile x>1 do//--------------------------------------------------------------------------------------// Reset flagsresult=99//thisBarIndex=0//--------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------// look for the most recent Lowest High bar LH)while high[x] < LH and x>0 DO // look for a new lowest high; skip when x=0LH=high[x] // set the latest LHx=x-1 // decrement the loopLHFound=1 // indicate that aLH has been foundHLFound=0 // ...and that the HL has not....wend//--------------------------------------------------------------------------------------// Output LH barif LHFound then//Draw where the LH was found...x=x+1//ThisBarIndex=Barindex//DRAWTEXT("LH*", barindex-x, high[x])x=x-1//LatestLH=LH//LatestHL=0Endif//--------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------// look for the most recent Highest Low bar (HL)WHILE low[x] >HL and x>0 DO// look for a new highest low; skip when x=0HL=low[x]// set the latest HLx=x-1 // decrement the loopHLFound=1 // indicate that a HL has been foundLHFound=0 // ...and that the LH has not....WEND//--------------------------------------------------------------------------------------// Output HL barif HLFound then// Draw where the HL was found...x=x+1//LatestHL=HL//LatestLH=0//ThisBarIndex=Barindex//DRAWTEXT("HL", barindex-x, low[x])x=x-1Endif//--------------------------------------------------------------------------------------//--------------------------------------------------------------------------------------// Output signal bar on chartif close>LH and close[1]<=LH thenresult=1//DRAWARROWUP(barindex, low)coloured(0,255,0)x=1// exit loopendifif close<HL and close[1]>=HL thenresult=2//DRAWARROWDOWN(barindex, high)coloured(255,0,0)x=1// exit loopendif//--------------------------------------------------------------------------------------// reset these counters before re-loooping...LH=99999999HL=0wend//Graph Resultif Result=1 ThenBUY 1 CONTRACTS AT MARKETENDIFIf Result=2 THENSELL AT MARKETENDIF1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on