Gamestudio Links
Zorro Links
Newest Posts
Price of entry with OrderDelay
by Zheka. 10/18/21 23:50
Easiest way to get 1m History?
by Grant. 10/18/21 22:31
Lapsa's very own thread
by Lapsa. 10/18/21 21:09
Is it possible to find robust systems?
by Mariano. 10/18/21 20:59
Orders not found
by dpn. 10/18/21 18:09
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/18/21 13:49
What are you working on?
by rayp. 10/17/21 12:01
AUM Magazine
Latest Screens
Tactics of World War I
Hecknex World
Scheherazade's Journey
Paradox Vector
Who's Online Now
7 registered members (Rtttt, Quad, Dooley, AndrewAMD, Zheka, Grant, RealSerious3D), 420 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mariano, KoenC, Cuttyflame, Chiller, Avedon
18694 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,641
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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