Daily Chart Signal intraday generation.

Questions about MultiCharts and user contributed studies.
MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Daily Chart Signal intraday generation.

Postby MeiHua » 22 Aug 2012

I have been using daily charts to enter a trade using the enter on close feature. However I would like to enter them on the 5 minute chart instead to allow me to use more fine tuning. I have used data2 correctly however when comparing the daily vs the modified 5 minute entry i am coming up with discrepancies. Either Trades are not taken or are taken in correctly. I have included both codes the original daily i got from a forum and my modified. I was using YM.

Code: Select all


{== START OF HEADER ==========================================================================



== END OF HEADER =============================================================================

== DEFINE ALL INPUTS AND VARIABLES ==========================================================}

Input: {-------------------------------------------------------------------------------------}
StopLoss$(1000), // Strategy Default Stoploss
BuyLevel(45), // RSI Buy Value
ExitLevel(65), // RSI Exit Value
TimeToEnter( 1600);


Variables: {---------------------------------------------------------------------------------}

LookBack(2), //RSI Look back period
RSI_Sum(0), // RSI sum variable
MA200(0), // 200 Moving Average value
MA5(0), // 5 Moving Average Value
TradeOK ( false); //Trade flag

{ === START OF MAIN PROGRAM ================================================================}

RSI_Sum = RSI(Close, Lookback) data2 + RSI(Close[1], Lookback) data2 + RSI(Close[2],Lookback) data2;
MA200 = Average(Close, 200)data2;


//Setting Trade Flag Based on Daily Charts
If ( RSI_Sum < BuyLevel ) And ( Close > MA200 ) Then
TradeOK = True
Else
TradeOK = False;

//Entry Logic + Time Check
If TradeOK = True and Time > TimeToEnter then
Buy ("RSI(2) Accum. LE") next bar at market;

{Debug}
IF MP[1] = 0 and MP[0] = 1 then
Print( "date ", date , "RSI ", RSI_Sum);

// Exit Logic
If ( MarketPosition <> 0 ) And ( RSI( Close, LookBack )data2 > ExitLevel ) Then sell this bar at close;

If ( StopLoss$ > 0 ) Then SetStopLoss( StopLoss$ );
{
If ( RSI_Sum < BuyLevel ) And ( Close > MA200 ) Then buy this bar at close;
}
{== END OF MAIN PROGRAM =====================================================================}
originally on the daily it was this

Code: Select all

RSI_Sum = RSI(Close,Lookback) + RSI(Close[1],Lookback) + RSI(Close[2],Lookback);
MA200 = Average(Close, 200);

If ( RSI_Sum < BuyLevel ) And ( Close > MA200 ) Then buy this bar at close;
If ( MarketPosition <> 0 ) And ( RSI( Close, LookBack ) > ExitLevel ) Then sell this bar at close;
If ( StopLoss$ > 0 ) Then SetStopLoss( StopLoss$ );
Image


I used print to debug date 1090625.00RSI 17.99
thats the value I got, however the close of the day already occurred and as we can see in the daily chart the RSI value is no longer meets the conditions.

When does the daily chart close and reload that value for a check by the 5 minute? I have been using 5 minutes after the close to enter but also tried 1 hour after. It doesn't effect it. I don't really know where i am going wrong and spinning my wheels. Any help would be great.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Daily Chart Signal intraday generation.

Postby Henry MultiСharts » 23 Aug 2012

Hello MeiHua,

In order to investigate this case please provide additional information:
1) What exact version and build number of MultiCharts are you running? (in MultiCharts go to Help tab-> About)
2) the workspace you are using
3) send us the study export file in Power Language editor->File->Export->export with dependent functions the study you are backtesting
4) Full sized screenshot demonstrating the issue with description
You can send it to my email support@multicharts.com

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: Daily Chart Signal intraday generation.

Postby MeiHua » 23 Aug 2012

Hello MeiHua,

In order to investigate this case please provide additional information:
1) What exact version and build number of MultiCharts are you running? (in MultiCharts go to Help tab-> About)
2) the workspace you are using
3) send us the study export file in Power Language editor->File->Export->export with dependent functions the study you are backtesting
4) Full sized screenshot demonstrating the issue with description
You can send it to my email support@multicharts.com
Version:
MultiCharts Version 8.0 Release (Build 5620)
Attachments
Development.wsp
(73.15 KiB) Downloaded 312 times

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: Daily Chart Signal intraday generation.

Postby MeiHua » 23 Aug 2012

No idea how to add multiple attachements sorry
Attachments
2012-08-23_15-33_MultiCharts.jpg
(217.53 KiB) Downloaded 520 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Daily Chart Signal intraday generation.

Postby TJ » 23 Aug 2012

No idea how to add multiple attachements sorry
click "Preview", then you can add another attachment.

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: Daily Chart Signal intraday generation.

Postby MeiHua » 23 Aug 2012

Here is the exported files. this forum is hard to use
Attachments
strategy export.pla
(15.03 KiB) Downloaded 330 times

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Daily Chart Signal intraday generation.

Postby Henry MultiСharts » 28 Aug 2012

Code: Select all

if date>=1090624 and date<=1090627 then begin
print("b#= ",barnumber," d= ", date, " t= ",time," RSI_Sum = ", RSI_Sum, " < BuyLevel = ", BuyLevel , " and c = ", c," > ma200 =", MA200 );
If ( RSI_Sum < BuyLevel ) And ( Close > MA200 ) Then
print("-------------------------------------------------------------------------------------------------");
end;

As we can see the script behavior is correct.
You need to output the values you are analyzing. Once you do that you will see that multiple close values (of 5 min bars on 25-06-2009) satisfy the conditions for entry order.
Daily RSI_Sum and ma200 values from 24-06-2009 are taken for calculation on 5 minute bars on 25 -06 -2009. This is the calculation rule for multiple data series because daily bar for the 25th is not closed when 5 min bars are closing at the same day.
The condition is not met on the daily bar that is why there is no entry order.

MeiHua
Posts: 26
Joined: 12 Aug 2012
Has thanked: 1 time

Re: Daily Chart Signal intraday generation.

Postby MeiHua » 29 Aug 2012

Code: Select all

if date>=1090624 and date<=1090627 then begin
print("b#= ",barnumber," d= ", date, " t= ",time," RSI_Sum = ", RSI_Sum, " < BuyLevel = ", BuyLevel , " and c = ", c," > ma200 =", MA200 );
If ( RSI_Sum < BuyLevel ) And ( Close > MA200 ) Then
print("-------------------------------------------------------------------------------------------------");
end;

As we can see the script behavior is correct.
You need to output the values you are analyzing. Once you do that you will see that multiple close values (of 5 min bars on 25-06-2009) satisfy the conditions for entry order.
Daily RSI_Sum and ma200 values from 24-06-2009 are taken for calculation on 5 minute bars on 25 -06 -2009. This is the calculation rule for multiple data series because daily bar for the 25th is not closed when 5 min bars are closing at the same day.
The condition is not met on the daily bar that is why there is no entry order.
I had to read this a few times to understand. But i think i got it. So the 5 minute bars and the daily bars are closing at different times so there are different values causing logic changes to not what i expected. Is there a specific time that the daily bars would be closed so that the 5 minute bars can be in sync? Or will there always be a disparity?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Daily Chart Signal intraday generation.

Postby Henry MultiСharts » 29 Aug 2012

The calculation is done on 5 min data series, you are referencing daily data series for your function calculation.
The script references the last closed daily bar. So on each 5 min bar it uses the function values that were calculated on the last day's close. Please have a look at the attached screenshot.
5 min and daily bar values would be in line on the minute bar corresponding to the daily bar close (so once a day).
Attachments
daily_close.png
(150.16 KiB) Downloaded 520 times


Return to “MultiCharts”