Hello!!
I am trying to edit a Strategy which needs historical calculated result to make the final conclusion. Its logic like the below:
Strategy A ()
{
private Function SAMPLE;
Create
{
SAMP01 = new Function SAMPLE;
}
StartCalc()
{
SAMP01.XXX = "give it attribute";
}
CalcBar()
{
Result01 = SAMP01.Result;
}
}
In CalcBar() Stage I execute calculate period 3 month data for instance, How could I execute another circulation of function result in extactly the same Period ??
For Example: Period(2001/1/1 ~2001/3/1)
===========
CalcBar() Period(2001/1/1 ~2001/3/1)
{
Result01 = SAMP01.Result;(SAMP01 result for 2001/1/1 ~2001/3/1)
// I'd like to generate another function SAMP02 based on Result01.
SAMP02 = new Function SAMPLE; (here error occured.)
Result02 = SAMP02.Result(SAMP02 result for 2001/1/1 ~2001/3/1)
}
==========
Could I perform a Strategy in certain period recursively? [SOLVED]
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Could I perform a Strategy in certain period recursively
Hello mustang,
All study body is calculated on all of the historic bars and then on all of realtime bars (see How studies are calculated). That means both functions are calculated at the same time and you do not need to calculate one after another. You can find an example of such calculation in prebuilt MACD indicator (PowerLanguage .Net Editor->File tab->Open->Indicator->MACD).
All study body is calculated on all of the historic bars and then on all of realtime bars (see How studies are calculated). That means both functions are calculated at the same time and you do not need to calculate one after another. You can find an example of such calculation in prebuilt MACD indicator (PowerLanguage .Net Editor->File tab->Open->Indicator->MACD).
Re: Could I perform a Strategy in certain period recursively
Heya~! Dear HenryHello mustang,
All study body is calculated on all of the historic bars and then on all of realtime bars (see software/index.php/4.1_How_Indicators_and_Signals_are_Calculated]How studies are calculated[/url]). That means both functions are calculated at the same time and you do not need to calculate one after another. You can find an example of such calculation in prebuilt MACD indicator (PowerLanguage .Net Editor->File tab->Open->Indicator->MACD).
I know that both of the functions are calculated simultaneously;however, in this senario that is just a situation to which I don't want.Because on the previous describe my function(SAMP01) and function(SAMP02) are related in frankly SAMP01 must be calculated through whole period(2001/1/1 ~2001/3/1 for instance) then based on SAMP01's result SAMP02 can be created and it also needs another calculation in the same period.
Well,I've studied previous articles and realized that there is no possible to create another Function during CalBar() Stage.Thus , I trying to go another way.
Are there any possibility to make multiple calculation for certain period during CalBar() Stage??
For Example:
Period : 2001/1/1 ~2001/3/1.(Daily Data) 90 Bars
Code: Select all
CalcBar()
private CalCount =0;
Double SumBarClosePrice =0;
{
SumBarClosePrice += Bars.Close[0];
if(Bars.CurrentBar == 90) && (CalCount <4) //Make 4 times calculate
{
//PrintLine("Number :"+ CalCount +" Calculation, SumResult :"+ SumBarClosePrice +");
SumBarClosePrice = 0;
this.CalcBar();
// Here I Found next CalcBar() can be called,but the Bars.Close[0] value will stop on
Bars.CurrentBar 90
CalCount ++;
}
}
- Henry MultiСharts
- Posts: 9165
- Joined: 25 Aug 2011
- Has thanked: 1264 times
- Been thanked: 2957 times
Re: Could I perform a Strategy in certain period recursively [SOLVED]
There is no way to do that. CalcBar cannot be called twice in the code.Are there any possibility to make multiple calculation for certain period during CalBar() Stage??
Here is what I can suggest for achieving your goal: calculate first function on a separate chat, once this calculation is finished start the calculation of the second function on its own chart, transfer the values of first function using Global Variables or Interprocess communication.
Re: Could I perform a Strategy in certain period recursively
Thanks for that I am trying to do on your way!!Hope I can get deal with it !!!