Refreshing chart with script

 

Hi,

I have a script that scans through the last completed bar of the charts and indicates the price action bars like pin bar, outside bar, inside bar etc.

the only problem i am facing is that when i run it and it access all charts one after the other for price action formation, sometimes it does not scans the last completed bars but few bars before that, seems like some chart refresh problem. when i run the script again immediately after the problem doesn't appear. since i am thinking along the line that it has something to do with refresh issue, i checked for function and i couldn't find anything other than refreshrates() which i used in my code. but still sometimes instead of scanning the last closed bars i get in result some previous bars.

can anyone advise what could be wrong here.

thanks,

Kya

 

I don't think this is the solution to your problem . . . but there is a function called WindowRedraw()

I have a Indicator that paints bars by Inside bar, Outside bar, Engulfing bar, DOJI, Pivot high, Pivot low, Double tops, Double bottoms, etc . . . I don't have the issue you describe.

Are you processing the old bars first as per real time, left to right, or the old bars last, right to left ?

 
i have an indicator version of the same and it works well. it doesnt work in the script version. i want to use a script which goes through all available charts in my trading platform and generate me a report of all price action bars based on analysis of trends and some other parameters based on previous bars. i am scanning the bars right to left (or new to old ).
 
kyahain:

Hi,

I have a script that scans through the last completed bar of the charts and indicates the price action bars like pin bar, outside bar, inside bar etc.

the only problem i am facing is that when i run it and it access all charts one after the other for price action formation, sometimes it does not scans the last completed bars but few bars before that, seems like some chart refresh problem. when i run the script again immediately after the problem doesn't appear. since i am thinking along the line that it has something to do with refresh issue, i checked for function and i couldn't find anything other than refreshrates() which i used in my code. but still sometimes instead of scanning the last closed bars i get in result some previous bars.

can anyone advise what could be wrong here.

Yes, it is a well known problem that charts which are not displayed do not get updated. There are various functions that request data which force a chart update but that can take several seconds per chart as the refresh data call gets queued up. Since your script is evidently causing a refresh of data that is half the problem solved. I recommend running two scripts: one to refresh the data and another to do the actual work. The first one can be a cut down version of the second one (eg not writing to an output file but doing everything else).

Actually you can do it all with one script, but you need to add delays (Sleep) to let the update take place. Run through all the charts first (but without writing the final output), then run through them again doing the output.

 
dabbler:

Yes, it is a well known problem that charts which are not displayed do not get updated. There are various functions that request data which force a chart update but that can take several seconds per chart as the refresh data call gets queued up. Since your script is evidently causing a refresh of data that is half the problem solved. I recommend running two scripts: one to refresh the data and another to do the actual work. The first one can be a cut down version of the second one (eg not writing to an output file but doing everything else).

Actually you can do it all with one script, but you need to add delays (Sleep) to let the update take place. Run through all the charts first (but without writing the final output), then run through them again doing the output.


Interesting point.... let me try this option.

thanks.

 

WINAPI

PostMessageA(hWnd, WM_COMMAND, 33324, 0); //Refresh Chart
Reason: