Different prices with priceHigh

Posted By: Chiller

Different prices with priceHigh - 10/09/21 15:55

Hello everyone,

I have coded a multi-asset strategy with a main asset and a second asset that is not for trading, but for helping me make decisions in trading the main asset.

(The main asset (here: "AAPL") is selected in the Zorro-window.)
Here is the beginning of the "function run" (ending FN means this is a function coded in the strategy):


function run()
{

SetNewAssetAndParametersFN(VIX_GB, "VIX"); // change to second Asset: VIX

var VIXPriceHighToday = priceHigh(0);
var VIXPriceHighBefore = priceHigh(1);
var VIXPriceCloseToday = priceClose(0);
SetNewAssetAndParametersFN(AAPL_GB, "AAPL"); // back to main asset



if(is(FIRSTRUN))
{
StartAssetPriceOfTheYearGB = priceClose(0);
if (AssetHasTradingPauseOver15MinFN()) // FN checks if Future
LengthOfAssetsDailyTradingPauseInDATEFormatGB = ScanAssetsLengthOfDailyTradingPauseInDATEFormatFN(); // set global var for detecting a new day in min-data
}

if (FirstBarOfTradingDayIncludingExtendedTradingHoursFN(0)) // bool-function: Checks if the daily trading pause is between given Bar-Offset and Bar-Offset before.
{
SetNewAssetAndParametersFN(VIX_GB, "VIX"); // change to VIX again

VIXPriceHighTodayX1 = priceHigh(0); // if data is missing in main asset, I here get the price of the VIX at that missing day (and not the same as in the priceHigh-Call above)
VIXPriceHighLastDayX1 = priceHigh(1);
VIXPriceCloseTodayX1 = priceClose(0);
VIXPriceCloseLastDayX1 = priceClose(1);
SetNewAssetAndParametersFN(AAPL_GB, "AAPL"); // back to main asset
}


// ....more code here, but not important for the mentioned problem, I think

}


the 2 ifs between the asset changes are just in the example, because I dont know if it is important that there is some code.
But they have nothing to do with the problem i mean here.

Both assets in self-created t6-data (of trading - view - exports).
Main asset in 1min-resolution. VIX in Daily resolution.

The 2 priceHigh - orders normaly give me the same price.

BUT:
If a day is missing in the main asset (that should be there because its a trading day and therefore VIX-data is present),
the second priceHigh gives me the value of the VIX of that missing day. But the first priceHigh just gives me the VIX of the Same day,
the main asset is in.

Fun-Fact: The priceClose(0) that follows following gives me the price of the present day (like the priceClose(0) some lines before) and not data of the day that is missing in the main asset.

Does anybody know why?

Fun-Fact2: I accidentally made a code, to test if an asset has missing days. I just needs a comparison of the 2 priceHigh(0)-results.



P.S.:
If this functions code is important:
endings: FP means parameter given to an function, GB means global (I am evil :))

int SetNewAssetAndParametersFN(int ParameterSetNumberFP, const string TickerOfAssetFP)
{
HistoryZone = TimeZoneOfAssetHistoryGB[ParameterSetNumberFP];
AssetMarket = TimeZoneOfAssetHistoryGB[ParameterSetNumberFP]; // Manual: "Market hours are determined by StartMarket and EndMarket in the AssetMarket time zone" Default: UTC(0)
AssetZone = TimeZoneOfAssetHistoryGB[ParameterSetNumberFP]; // Keine Ahnung auf was das Einfluss hat. UTC (0) ist nach Manual der Standard.

// TimeFrame = 1; FrameOffset = 0;

LookBack = LookBackInBarsPerAssetGB[ParameterSetNumberFP];

return asset(TickerOfAssetFP);
}
Posted By: jcl

Re: Different prices with priceHigh - 10/12/21 13:31

I am not sure that I understood the problem, but priceHigh(1) is the high of the last time period, not the high of the last day. Make sure that the bar period is not smaller than your historical data resolution, and that the main asset is selected in your script before any secondary assets.

https://manual.zorro-project.com/asset.htm
© 2024 lite-C Forums