Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 559 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Different prices with priceHigh #484326
10/09/21 15:55
10/09/21 15:55
Joined: Oct 2021
Posts: 4
C
Chiller Offline OP
Guest
Chiller  Offline OP
Guest
C

Joined: Oct 2021
Posts: 4
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);
}

Last edited by Chiller; 10/09/21 19:25.
Re: Different prices with priceHigh [Re: Chiller] #484350
10/12/21 13:31
10/12/21 13:31
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
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


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1