Hi,

I would like see signals in One chart based on conditions of other chart . Example: When price touches VWAP in Index , i would like to get signal in Option chart corresponding bar. Is it possible …appreciate your time

Hi,

I would like see signals in One chart based on conditions of other chart . Example: When price touches VWAP in Index , i would like to get signal in Option chart corresponding bar. Is it possible …appreciate your time

SetForeign is what you’re after. It allows you to reference the arrays of another symbol (eg the Index) and use the result with the current symbol (your Option).

I’m assuming you know how to calculate the VWAP for the current day. If not here’s one way (unverified).

To combine them:

```
function VWAPCalc(CloseArray, VolumeArray)
{
// VWAP Caluatated here
VWAP = ...
return VWAP;
}
IndexSymbol = "$SPX";
SetForeign(IndexSymbol);
IndexVWAP = VWAPCalc(C, V);
IndexPriceCrossedVWAP = Cross(C, IndexVWAP) OR Cross(IndexVWAP, C);
RestorePriceArrays();
// Show signal on current symbol's chart
PlotShapes(IsTrue(IndexPriceCrossedVWAP) * shapeSmallCircle, colorGreen, 0, L, -12);
```

4 Likes

I am trying use same formula for “TIME WAP” for Foreign symbol Unable to… appreciate anyone time …

```
function ATVWAPCalc(CloseArray, VolumeArray)
{
P11 = 093000;
// TVWAP Caluatated here
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == P11, BarIndex());
TodayClose = Sum(C,Bars_so_far_today);
TodayHigh = Sum(H,Bars_so_far_today);
TodayLow = Sum(L,Bars_so_far_today);
TodayOpen = Sum(O,Bars_so_far_today);
TWAP = (TodayClose + TodayHigh + TodayLow + TodayOpen)/4 ;
IIf (BarIndex() >= StartBar, ATWAP = TWAP / Bars_so_far_today,0);
return ATWAP;
}
IndexSymbol = "$SPX" ;
SetForeign(IndexSymbol);
//IndexVWAP = VWAPCalc(C, V);
IndexTWAP = ATVWAPCalc ( ?? , ???) ;
```

Not sure what code to use

- inplace of closearray , volume array
- and corresponding values to caluclate

```
1) ATVWAPCalc(CloseArray, VolumeArray)
2) IndexTWAP = ATVWAPCalc ( ?? , ???) ;
```

thanks for your time

still unable to get it … I am trying calculate Foreign " TimeWAP " in another chart … Appreciate any one help

Any help ? Probably no one paying attention because it say’s solved ? or may be just a dumb question ?

Save a static variable in the chart you calculate timewap, in others charts you read the static variable

I think i was not paying attention as @HelixTrader provided solution in 2nd post it self

```
/// To calculate time based weighted price of foreign symbol
//// http://forum.amibroker.com/t/signal-in-one-symbol-chart-based-on-condition-in-another-symbol-chart/
FIndexSymbol = ParamStr("Foreign Symbol ", "$SPX") );
SetForeign(FIndexSymbol);
P11 = 093000; // Market opening Time
// TWAP Calculated here
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == P11, BarIndex());
TodayClose = Sum(C,Bars_so_far_today);
TodayHigh = Sum(H,Bars_so_far_today);
TodayLow = Sum(L,Bars_so_far_today);
TodayOpen = Sum(O,Bars_so_far_today);
TWAP = (TodayClose + TodayHigh + TodayLow + TodayOpen)/4 ;
IIf (BarIndex() >= StartBar, ATWAP = TWAP / Bars_so_far_today,0); // ATWAP is Time WAP of Foreign symbol
RestorePriceArrays();
```

solved my problem . Pardon my ignorance and thanks @awilson for trying to help me . Don’t know how to use static variables as you suggested . But thanks for your time

1 Like